package com.adityayadav.parallelism.core;

import com.adityayadav.parallelism.core.ThreadPool;

public abstract class RecurringTask implements ITask{

	protected ThreadPool taskThreadPool;
	
	public RecurringTask(ThreadPool taskThreadPool){
		this.taskThreadPool = taskThreadPool;
	}
	
	
	@Override
	public void commit() throws Exception {
		taskThreadPool.addTask(this);
	}

	@Override
	public void initialize() throws Exception {
		
		
	}

	@Override
	public void rollback() throws Exception {
		taskThreadPool.addTask(this);
	}

	@Override
	public void run() throws Exception {
		process();
	}

	public abstract void process() throws Exception;
	
}
